package com.ruoyi.web.controller.storeEmployeeCommission;


import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StoreEmployeeCommissionSetting;
import com.ruoyi.system.service.IStoreEmployeeCommissionSettingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 门店员工提成设置，按门店配置多种提成规则Controller
 *
 * @author ruoyi
 * @date 2025-05-13
 */
@Api(tags="门店员工提成设置")
@RestController
@RequestMapping("/system/storeEmployeeCommissionSetting")
public class StoreEmployeeCommissionSettingController extends BaseController
{
    @Autowired
    private IStoreEmployeeCommissionSettingService storeEmployeeCommissionSettingService;

    /**
     * 查询门店员工提成设置列表
     */
    @ApiOperation("查询门店员工提成设置列表")
    @PreAuthorize("@ss.hasPermi('system:setting:list')")
    @GetMapping("/list")
    public TableDataInfo list(@RequestParam(required = false) String storeName)
    {
        startPage();
        List<StoreEmployeeCommissionSetting> list = storeEmployeeCommissionSettingService.selectStoreEmployeeCommissionSettingListByName(storeName);
        return getDataTable(list);
    }

    /**
     * 导出门店员工提成设置列表
     */
    @ApiOperation("导出门店员工提成设置列表")
    @PreAuthorize("@ss.hasPermi('system:setting:export')")
    @Log(title = "门店员工提成设置，按门店配置多种提成规则", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, @RequestParam(required = false) String storeName)
    {
        List<StoreEmployeeCommissionSetting> list = storeEmployeeCommissionSettingService.selectStoreEmployeeCommissionSettingListByName(storeName);
        ExcelUtil<StoreEmployeeCommissionSetting> util = new ExcelUtil<StoreEmployeeCommissionSetting>(StoreEmployeeCommissionSetting.class);
        util.exportExcel(response, list, "门店员工提成设置，按门店配置多种提成规则数据");
    }

    /**
     * 通过id获取门店员工提成设置详细信息
     */
    @ApiOperation("通过id获取门店员工提成设置详细信息")
    @PreAuthorize("@ss.hasPermi('system:setting:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(storeEmployeeCommissionSettingService.selectStoreEmployeeCommissionSettingById(id));
    }

    /**
     * 新增门店员工提成设置
     */
    @ApiOperation("新增门店员工提成设置")
    @PreAuthorize("@ss.hasPermi('system:setting:add')")
    @Log(title = "门店员工提成设置，按门店配置多种提成规则", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StoreEmployeeCommissionSetting storeEmployeeCommissionSetting)
    {
        return toAjax(storeEmployeeCommissionSettingService.insertStoreEmployeeCommissionSetting(storeEmployeeCommissionSetting));
    }

    /**
     * 修改门店员工提成设置
     */
    @ApiOperation("修改门店员工提成设置")
    @PreAuthorize("@ss.hasPermi('system:setting:edit')")
    @Log(title = "门店员工提成设置，按门店配置多种提成规则", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StoreEmployeeCommissionSetting storeEmployeeCommissionSetting)
    {
        return toAjax(storeEmployeeCommissionSettingService.updateStoreEmployeeCommissionSetting(storeEmployeeCommissionSetting));
    }

    /**
     * 通过id批量删除门店员工提成设置信息
     */
    @ApiOperation("通过id批量删除门店员工提成设置信息")
    @PreAuthorize("@ss.hasPermi('system:setting:remove')")
    @Log(title = "门店员工提成设置，按门店配置多种提成规则", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(storeEmployeeCommissionSettingService.deleteStoreEmployeeCommissionSettingByIds(ids));
    }
}
